/*
 * 文 件    名:  Lines.java
 * 创建日期:  2012-11-29下午4:32:22
 * 版          权:  Epro Technologies Co., Ltd. Copyright 2011-2012,  All rights reserved
 * 作          者:  xrj66010
 */
package com.weipu.common.facade.model;

import java.io.Serializable;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

import com.weipu.common.constants.ServerConstant;

/**
 * @Description 订单详情中的商品信息
 * @version [版本号, 2012-11-29]
 * @see [相关类/方法]
 * @since [产品/模块版本]
 * 
 * @author xrj66010
 */
public class Lines implements Serializable,Parcelable{

	private static final long serialVersionUID = 5643815161170083890L;

	int GiftQty;

	String Notes;

	String Name;
	
	public String getName() {
		return Name;
	}

	public void setName(String name) {
		Name = name;
	}

	int OrderedQty;

	int Sku;

	double UnitCost;

	double UnitPrice;

	// 产品小图
	String SmileImageUrl;

	//PreviewOrder 传参
	int Qty;
	double SellingPrice;
	public int getQty() {
		return Qty;
	}

	public void setQty(int qty) {
		Qty = qty;
	}

	public double getSellingPrice() {
		return SellingPrice;
	}

	public void setSellingPrice(double sellingPrice) {
		SellingPrice = sellingPrice;
	}

	public int getGiftQty() {
		return GiftQty;
	}

	public void setGiftQty(int giftQty) {
		GiftQty = giftQty;
	}

	public String getNotes() {
		return Notes;
	}

	public void setNotes(String notes) {
		Notes = notes;
	}

	public int getOrderedQty() {
		return OrderedQty;
	}

	public void setOrderedQty(int orderedQty) {
		OrderedQty = orderedQty;
	}

	public int getSku() {
		return Sku;
	}

	public void setSku(int sku) {
		Sku = sku;
	}

	public double getUnitCost() {
		return UnitCost;
	}

	public void setUnitCost(double unitCost) {
		UnitCost = unitCost;
	}

	public double getUnitPrice() {
		return UnitPrice;
	}

	public void setUnitPrice(double unitPrice) {
		UnitPrice = unitPrice;
	}

	@Override
	public String toString() {
		return "Lines [GiftQty=" + GiftQty + ", Notes=" + Notes
				+ ", OrderedQty=" + OrderedQty + ", Sku=" + Sku + ", UnitCost="
				+ UnitCost + ", UnitPrice=" + UnitPrice + ", Qty="+Qty+", SellingPrice="+SellingPrice+"]";
	}

	public String getSmileImageUrl() {
		return SmileImageUrl;
	}

	public void setSmileImageUrl(String smileImageUrl) {
		SmileImageUrl = smileImageUrl;
	}

	/**
	 * Json转Lines对象
	 * 
	 * @param jo
	 *            传入的json对象
	 * @return 转化后的json对象
	 */
	public Lines json2Object(JSONObject jo) {
		if (jo == null) {
			return null;
		}
		Lines l = new Lines();
		if (jo.optString(ServerConstant.Order.SMILEIMAGEURL) != JSONObject.NULL
				&& !jo.isNull(ServerConstant.Order.SMILEIMAGEURL)) {
			l.setSmileImageUrl(jo
					.optString(ServerConstant.Order.SMILEIMAGEURL));
		}
		if (jo.optString(ServerConstant.Order.NOTES) != JSONObject.NULL
				&& !jo.isNull(ServerConstant.Order.NOTES)) {
			l.setNotes(jo
					.optString(ServerConstant.Order.NOTES));
		}
		if (jo.optString(ServerConstant.Order.NAME) != JSONObject.NULL
				&& !jo.isNull(ServerConstant.Order.NAME)) {
			l.setName(jo
					.optString(ServerConstant.Order.NAME));
		}
		l.setGiftQty(jo.optInt(ServerConstant.Order.GIFTQTY));
		l.setOrderedQty(jo.optInt(ServerConstant.Order.ORDEREDQTY));
		l.setSku(jo.optInt(ServerConstant.Order.SKU));
		l.setUnitCost(jo.optDouble(ServerConstant.Order.UNITCOST));
		l.setUnitPrice(jo.optDouble(ServerConstant.Order.UNITPRICE));
		return l;
	}
    
	public Lines(){}
	public Lines(Parcel p){
		GiftQty = p.readInt();
		Notes = p.readString();
		Name = p.readString();
		OrderedQty = p.readInt();
		Sku = p.readInt();
		UnitCost = p.readDouble();
		UnitPrice = p.readDouble();
		SmileImageUrl = p.readString();
		Qty = p.readInt();
		SellingPrice = p.readDouble();
	}
	
	public static final Parcelable.Creator<Lines> CREATOR = new Creator<Lines>() {
		
		@Override
		public Lines[] newArray(int size) {
			// TODO Auto-generated method stub
			return new Lines[size];
		}
		
		@Override
		public Lines createFromParcel(Parcel p) {
			// TODO Auto-generated method stub
			return new Lines(p);
		}
	};
	
	@Override
	public int describeContents() {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public void writeToParcel(Parcel p, int flags) {
		// TODO Auto-generated method stub
		p.writeInt(GiftQty);
		p.writeString(Notes);
		p.writeString(Name);
		p.writeInt(OrderedQty);
		p.writeInt(Sku);
		p.writeDouble(UnitCost);
		p.writeDouble(UnitPrice);
		p.writeString(SmileImageUrl);
		p.writeInt(Qty);
		p.writeDouble(SellingPrice);
	}
	
	

}
